package com.hainatong.jcmvvmbase.login.fragment;

import android.view.View;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.StringUtils;
import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentUserInfoBinding;
import com.hainatong.jcmvvmbase.login.entity.UserBean;
import com.hainatong.jcmvvmbase.utils.GsonUtil;
import com.hainatong.mvvmbase.base.NoViewModel;

public class UserInfoFragment extends MvvmLazyFragment<FragmentUserInfoBinding , NoViewModel>
{
    private static String TAG = UserInfoFragment.class.getSimpleName();
    private UserBean mUser;

    @Override
    protected void initView(View view)
    {
       String userStr = SPUtils.getInstance(Constants.CONFIG).getString(Constants.LOCAL_USER , "");
       if( !StringUtils.isEmpty( userStr ))
       {
           LogUtils.eTag(TAG,userStr);
           mUser = GsonUtil.json2Obj(userStr,UserBean.class );
       }
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_user_info;
    }

    @Override
    public int getBindingVariable() {
        return 0;
    }

    @Override
    protected void onRetryBtnClick() {

    }


    @Override
    protected void lazyLoad()
    {
        if(ObjectUtils.isNotEmpty( mUser ))
        {
            LogUtils.eTag( TAG , mUser.getName() );
            viewDataBinding.setUserBean( mUser );
            viewDataBinding.executePendingBindings();
        }
    }
}
